#!/usr/bin/env ./jsrun

var fib = function(n){ return n <= 1 ? 1 : fib(n-1) + fib(n-2) };

var make2 = function(f, n){
	for(var i=0; i<n; ++i)
		(function(i){setTimeout(f, 0)})(i);
	/*
	if(n <= 0) return;
	setTimeout(function(){
		f(n);
		make2(f, n-1);
	}, 0);
	*/
};



make(function(){
	var id = getThreadId();
	//for(var i=0; i<10; ++i)
		alert('thread ' + id + ': ' + fib(20));
}, 100);

alert("ALL DONE!!!");

sleep(100000);
